
<?php

$cateid = $_GET["cateid"];
$minid = $_GET["minid"];

mysql_connect("localhost", "texadnjq_piccms", "123456") or die("Could not connect: " . mysql_error());

mysql_query("SET NAMES UTF8");
mysql_query("set character_set_client=utf8"); 
mysql_query("set character_set_results=utf8");

mysql_select_db("texadnjq_piccms");

$sql;
if($cateid==0){
	if($minid==0){
		$sql="SELECT * FROM pc_article where status=1 order by id desc LIMIT 5";
	}else{
		$sql="SELECT * FROM pc_article where status=1 and id<".$minid." order by id desc LIMIT 5";
	}
}else{
	if($minid==0){
		$sql="SELECT * FROM pc_article where status=1 and cid=".$cateid." order by id desc LIMIT 5";
	}else{
		$sql="SELECT * FROM pc_article where status=1 and cid=".$cateid." and id<".$minid." order by id desc LIMIT 5";
	}
}

$rs = mysql_query($sql);
$items = array();
while($row = mysql_fetch_object($rs)){
	array_push($items, $row);
}
$result["rows"] = $items;

echo json_encode($result);